labels = []
boxs = []
images = []
classIndexs = []

#???image
with open('images.txt') as images_file:
    for image_id,line in enumerate(images_file):
        #print(line.strip().split()[1])
        #?????,????,?????????,?????,??
        filename=line.strip().split(",")[1]
        images.append("./images/bss/"+filename)

img_train = '/home/incar/data/bss'
img_val = './images/valid/'

#https://www.pythonf.cn/read/108114

import numpy as np
import os

np.random.seed(100)
np.random.shuffle(images)

train_ratio = 0.9
train_num = int(len(images) * train_ratio)

# ????????????
img_list_train = images[:train_num]
img_list_val = images[train_num:]

#??????
with open("train.txt", "w") as train_file_location:
    for item in img_list_train:
        train_file_location.write(item)
        train_file_location.write("\r\n")


with open("val.txt", "w") as val_file_location:
    for item in img_list_val:
        val_file_location.write(item)
        val_file_location.write("\r\n")
